/**
 * Created by xinxinran on 2018/7/18.
 */
'use strict';

class ValidateError extends Error {
    constructor(msg) {
        super();
        this.message = msg;
        this.name = 'ValidateError';
    }
}

export default {
    isWeChat() {
        let ua = navigator.userAgent.toLowerCase();
        return ua.indexOf('micromessenger') > -1;
    },
    isMobile(val) {
        return /^1[35678]\d{9}$/.test(val);
    },
    isValidateError(err) {
        err = err || {};
        return Object.getPrototypeOf(err).constructor === Error && err.name === 'ValidateError';
    },
    newValidateError(msg) {
        return new ValidateError(msg);
    }
};
